package com.mlz.controller;



import com.mlz.domain.dto.PageDTO;
import com.mlz.domain.query.UserQuery;
import com.mlz.domain.vo.UserVO;
import com.mlz.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author eoron
 * @since 2025-01-10
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 根据用户id查询用户
     * @param userId
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据用户id查询用户")
    public UserVO queryById(@PathVariable("id") Long userId) {
        //基于自定义的service方法查询
        return userService.queryUserAndAddressById(userId);
    }


    @GetMapping("/page")
    public PageDTO<UserVO> queryByPage(UserQuery  userQuery) {

        return userService.queryUsersPage(userQuery);
    }

}
